package com.xyq.common.rabbitmq;

import com.xyq.common.core.constants.RabbitMQConstants;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {
    @Bean
    public Queue workQueue() {   // 声明RabbitMQ
        return new Queue(RabbitMQConstants.OJ_WORK_QUEUE, true);
    }

    @Bean                // 配置json转换器 , 后面操作的都是一个个对象,需要转换器
    public MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }
}